import tensorflow as tf
from tensorflow.keras.models import load_model
from imagenette.Utils.data_generator import test_generator
from imagenette.Utils.image_plot import plot_image

# 读取测试集
test_gen = test_generator(
    data_dir='../dataset/test',
    target_size=(160, 160),
    batch_size=32,
    class_mode='categorical'
)

# 显示测试集的15张图片
test_data, test_labels = test_gen.next()
plot_image(test_data, test_labels, list(test_gen.class_indices.keys()))

# 读取模型
model_path = '../Models/my_model_2020-08-18'
loaded_model = load_model(model_path)

# 模型测试
loss, accuracy = loaded_model.evaluate(x=test_gen)
